package p4;

/**
 * @author krystal
 * @date 2022/11/10 9:24
 */
public class Demo5 {
    public static void main(String[] args) {
        System.out.println(sum(1234));  //10
    }

    public static int sum(int num){
        if (num < 10){
            return num;
        }
        return num % 10 +sum( num / 10);
    }
}
